#include<bits/stdc++.h>
using namespace std;
int main()
{
    freopen("detect1.in","r",stdin);
    freopen("detect1.out","w",stdout);
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int m,n,L,V,t,p[3001],ans1=0,ans2=0,sx[3001]={0};
    bool b[3001][3001]={0};
    struct car{int d,v,a;} c[3001];
    struct row{int s=0;vector<int> x;} sy[3001];
    cin>>t;
    while(t--){
        cin>>m>>n>>L>>V;
        for(int i=0;i<n;i++) cin>>c[i].d>>c[i].v>>c[i].a;
        for(int i=0;i<m;i++) cin>>p[i];
        for(int i=0;i<n;i++){
            if(c[i].d>p[m-1]) continue;
            if(c[i].a==0){
                if(c[i].v<=V) continue;
                else{
                    ans1++;
                    for(int j=lower_bound(p,p+m,c[i].d)-p;j<m;j++) b[i][j]=1;
                }
            }else if(c[i].a>0){
                if(c[i].v>V){
                    ans1++;
                    for(int j=lower_bound(p,p+m,c[i].d)-p;j<m;j++) b[i][j]=1;
                }else{
                    long double d=(V*V-c[i].v*c[i].v)*0.5/c[i].a;
                    if(c[i].d+d>=p[m-1]) continue;
                    ans1++,b[i][upper_bound(p,p+m,c[i].d+d)-p]++;
                    for(int j=ce;j<lower_bound(p,p+m,c[i].d+d)-p;j++) b[i][j]=1;
                }
            }else{
                if(c[i].v<=V) continue;
                else{
                    long double d=(c[i].v*c[i].v-V*V)*0.5/c[i].a;
                    int ce=lower_bound(p,p+m,c[i].d)-p;
                    if(p[ce]>=c[i].d+d) continue;
                    ans1++;
                    for(int j=ce;j<lower_bound(p,p+m,c[i].d+d)-p;j++) b[i][j]=1;
                }
            }
            if(b[i][0]) sx[i]++,sy[0].s++,sy[0].x.push_back(i);
            for(int j=1;j<m;j++){
                b[i][j]+=b[i][j-1];
                if(b[i][j]) sx[i]++,sy[j].s++,sy[j].x.push_back(i);
                cout<<b[i][j-1];
            }
            cout<<b[i][m-1]<<"\n";
        }
    }
    return 0;
}
